package rs.edu.fit.setupdata.actions;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import rs.edu.fit.model.Student;

public class GenerateStudents {
	private static String []firstNames = {
		"Nikola", "Luka", "Marko", "Stefan", "Aleksa", "Lazar", "Aleksandar", 
		"Filip", "Nemanja", "Milos", "Uros", "Jovan", "Petar", "Djordje",
		"Ognjen", "Dusan", "Vuk", "Veljko", "Andrej", "Mateja"
	};
	private static String []lastNames = {
		"Ceha", "Manasijevic", "Sokcevic", "Jovanovic", "Micic", "Jovicic", "Miric",
		"Mitrovic", "Cosic", "Cimes", "Vukic", "Pesic", "Milic", "Cicovic", 
		"Jovancic", "Stamenovic", "Ilic", "Kitic", "Bubalo", "Babic"
	};
	
	private static Random r = new Random();
	private static final int NUM_OF_STUDENTS = 20;
	
	private GenerateStudents() {
		
	}
	
	public static final List<Student> createList(final int number) {
		List<Student> lStudents = new ArrayList<Student>();
		for (int i=0; i<number; i++) {
			int randomInteger = r.nextInt(NUM_OF_STUDENTS);
			String firstName = firstNames[randomInteger];
			String lastName = lastNames[randomInteger];
			String indexNumber = generateIndexNumber();
			int yearOfStudy;
			if (i % 3 == 0) {
				yearOfStudy = 3;
			} else if (i % 2 == 0) {
				yearOfStudy = 2;
			} else {
				yearOfStudy = 1;
			}
			lStudents.add( new Student(firstName, lastName, yearOfStudy, indexNumber));
		}
		return lStudents;
	}
	
	public static String generateIndexNumber() {
		return  Long.toHexString(Double.doubleToLongBits(Math.random()));
	}
	
}
